window.onload = function() {
}

function supplier_supplierSave(strFlag) {
    var strSupplierNo = "";
    var strDataVersion = "";
    if (strFlag == "2") {
        strSupplierNo = getValue("hidSupplierNo");
        strDataVersion = getValue("hidDataVersion");
    }
    ajaxRequest(getHost()+"supplier/supplierEdit/save", {
        "SupplierNo"    : strSupplierNo,
        "SupplierId"    : getValue("txtSupplierId"),
        "SupplierName"  : getValue("txtSupplierName"),
        "SaleTp"        : getRadioValue("rdoSaleTp"),
        "ProvCode"      : getSelectedValue("selProv"),
        "City"          : getValue("txtCity"),
        "District"      : getValue("txtDistrict"),
        "SupplierStatus"    : getRadioValue("rdoSupplierStatus"),
        "SupplierScale" : getRadioValue("rdoSupplierScale"),
        "ContractNo"    : getValue("txtContractNo"),
        "Tel"           : getValue("txtTel"),
        "Mobile"        : getValue("txtMobile"),
        "Fax"           : getValue("txtFax"),
        "Email"         : getValue("txtEmail"),
        "QQ"            : getValue("txtQQ"),
        "MSN"           : getValue("txtMSN"),
        "Ali"           : getValue("txtAli"),
        "Homepage"      : getValue("txtHomepage"),
        "DataVersion"   : strDataVersion,
        "PaymentTp1"    : getRadioValue("rdoPaymentTp1"),
        "Account1"      : getValue("txtAccount1"),
        "PaymentTp2"    : getRadioValue("rdoPaymentTp2"),
        "Account2"      : getValue("txtAccount2"),
        "PaymentTp3"    : getRadioValue("rdoPaymentTp3"),
        "Account3"      : getValue("txtAccount3"),
        "Flag"          : strFlag
    }, supplier_supplierCallback);
}

function supplier_supplierDeleteConfirm() {
    Jconfirm(getMessage("INFO-00005"), null, supplier_supplierDelete);
}

function supplier_supplierDelete() {
    ajaxRequest(getHost()+"supplier/supplierEdit/delete", {
        "SupplierNo"    : getValue("hidSupplierNo"),
        "DataVersion"   : getValue("hidDataVersion")
    }, supplier_supplierCallback);
}

function supplier_supplierCallback(data) {
    if(data.count != 0) {
        window.location.href=getHost()+"supplier/supplierList/index/ReturnFg/" + data.ReturnFg;
    } else {
        Jconfirm(data.ReturnFg, null, null);
        setDisabled("btnSave", true);
        setDisabled("btnDelete", true);
    }
}

function supplier_paymentChecked(e) {
    setDisabled(e.name.replace("rdoPaymentTp","txtAccount"), getRadioValue(e.name) == "0");
}